<%-- 
    Document   : add_student_post
    Created on : Nov 24, 2011, 8:18:50 PM
    Author     : THIENSUHACK
--%>

<%@page import="GetData.CharsetFilter"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="GetData.DataWS"%>
<%@page import="dktc_ws.Lophoc"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
 request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html; charset=UTF-8"); 
    
    Lophoc lh = new Lophoc();
    lh.setMamh(request.getParameter("mamonhoc"));
    lh.setMagv(Integer.parseInt(request.getParameter("magiangvien")));
    lh.setMahk(Integer.parseInt(request.getParameter("mahocky")));
    lh.setSoluongdktoda(Integer.parseInt(request.getParameter("sisotoida")));
    lh.setThu(Short.parseShort(request.getParameter("thu")));
    lh.setCa(Short.parseShort(request.getParameter("ca")));
    int sophong = Integer.parseInt(request.getParameter("sophong"));
    int result=0;
   DataWS a=new DataWS();
   
result = a.themlophoc(lh.getMamh(), lh.getMagv(), lh.getSoluongdktoda(), lh.getMahk(), lh.getThu(),lh.getCa());
    
List<Lophoc> dslop = a.laydanhsachlophoc(-1);
Lophoc lop;
int malop = -1;
for (int i=0;i<dslop.size();i++)
       {
    lop = dslop.get(i);
    if (lop.getMagv() == lh.getMagv() && lop.getMahk() == lh.getMahk() && lop.getMamh().compareTo(lh.getMamh())==0 && lop.getThu() == lh.getThu() && lop.getCa() == lh.getCa())
        malop = lop.getMaLop();
}

int result2 = a.themCTPhong(sophong, malop);
   if(result>0)
             {
       out.print("thanh cong");
       response.sendRedirect("/DKTC/admin/index.jsp?page=list_class");

   }
   else
       out.print("that bai");
           %>